load mnist_knn_cos_trrr;
trnn = nn;
load mnist_knn_cos_trts;
tsnn = nn;
load mnist_train;
load mnist_test;

tserr = zeros(20,1);
trerr = zeros(20,1);

trerr(1) = calerr(Yl(trnn(:,1)),Yl);
tserr(1) = calerr(Yl(tsnn(:,1)),Yu);

for i = 2:20
    Ytr = mode(Yl(trnn(:,1:i)),2);
    trerr(i) = calerr(Ytr,Yl);
    Yts = mode(Yl(tsnn(:,1:i)),2);
    tserr(i) = calerr(Yts,Yu);
end
x = 1:20;
plot(x,trerr,x,tserr)